<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>生成java模板</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.min.js"></script>
    <!-- import CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/theme-chalk/index.min.css" rel="stylesheet">
    <!-- import JavaScript -->
    <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.1/index.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body>
<div>
    <div id="app">
        <div>
            <el-form ref="form" :model="form" label-width="120px">
                <el-form-item label="请输入ddl">
                    <el-input v-model="form.ddl" type="textarea"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">生成模板</el-button>
                    <el-button>Cancel</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <h1>result</h1>
            <div>
                <h3>entity</h3>
                <pre >
                    <xmp v-html="result.entity"></xmp>
                </pre>
            </div>
            <div>
                <h3>mapper</h3>
                <pre >
                      <xmp v-html="result.mapper"></xmp>
                </pre>
            </div>
            <div>
                <h3>service</h3>
                <pre >
                      <xmp v-html="result.service"></xmp>
                </pre>
            </div>
            <div>
                <h3>serviceImpl</h3>
                <pre>
                      <xmp v-html="result.serviceImpl"></xmp>
                </pre>
            </div>
            <div>
                <h3>controller</h3>
                <pre>
                      <xmp v-html="result.controller"></xmp>
                </pre>
            </div>
            <div>
                <h3>vuelist</h3>
                <pre>
                      <xmp v-html="result.vuelist"></xmp>
                </pre>
            </div>
            <div>
                <h3>vuemodify</h3>
                <pre>
                      <xmp v-html="result.vuemodify"></xmp>
                </pre>
            </div>
            <div>
                <h3>帮助</h3>
                <div>
                    utils
                        --Lodash
                        --R
                </div>
                <pre v-html="staticHtml">
                </pre>
            </div>
        </div>

    </div>

</div>

<script>
    const staticHtml=`
package com.example.demo.utils;

public class Lodash {
    public static boolean isNil(Object str) {
        if (str == null) {
            return true;
        }
        if ("".equals(str)) {
            return true;
        }
        return false;
    }
    public static boolean isNil(Integer str) {
        if (str == null) {
            return true;
        }
        if ("".equals(str)) {
            return true;
        }
        if(str==0){
            return true;
        }
        return false;
    }
}

====

     package com.example.demo.utils;

import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 *
 * @author Mark sunlightcs@gmail.com
 */
public class R extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public R() {
        put("code", 0);
        put("msg", "success");
    }

    public static R error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static R error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static R error(int code, String msg) {
        R r = new R();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static R ok(String msg) {
        R r = new R();
        r.put("msg", msg);
        return r;
    }

    public static R ok(Map<String, Object> map) {
        R r = new R();
        r.putAll(map);
        return r;
    }

    public static R ok() {
        return new R();
    }

    public R put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}`
    new Vue({
        el: "#app",
        data() {
            return {
                result: {entity: ""},
                form: {
                    name: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: '',
                    staticHtml
                }
            }
        },
        methods: {
            onSubmit() {
                axios.post("/createTemplate", {ddl: this.form.ddl}).then(res => res.data).then(res => {
                    this.$data.result.entity = res.entity
                    this.$data.result.mapper = res.mapper
                    this.$data.result.service = res.service
                    this.$data.result.serviceImpl = res.serviceImpl
                    this.$data.result.controller = res.controller
                    this.$data.result.vuelist = res.vuelist
                    this.$data.result.vuemodify = res.vuemodify
                })
            }
        }

    })
</script>
</body>
</html>